<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body style="height: 100%; width: 100%; overflow: hidden; border: none;">
		<script type="text/javascript">  
		$("document").ready(function(){  
			  //加载fckeditor
			var oFCKeditor = new FCKeditor("description"); 
			oFCKeditor.BasePath='${pageContext.request.contextPath}/fckeditor/'; 
			oFCKeditor.Height=300 ;
			oFCKeditor.ReplaceTextarea(); 
			 //加载商品类型
				$("#proTypeid").combobox({
					valueField:'id', //值字段
				    textField:'protypename', //显示的字段
				    url:'${pageContext.request.contextPath}/sys/product.do?findByProType',
				    panelHeight:'auto',
				    required:true,
					editable:false,//不可编辑，只能选择
					onChange:function(n,o){ 
					}
				}); 
				//加载商品品牌
				$("#proBrandid").combobox({
					valueField:'id', //值字段
				    textField:'brandname', //显示的字段
				    url:'${pageContext.request.contextPath}/sys/product.do?findByProBrand',
				    panelHeight:'auto',
				    required:true,
					editable:false,//不可编辑，只能选择
					onChange:function(n,o){ 
					}
				});
				//加载运费模板
				$("#proFreightid").combobox({
					valueField:'id', //值字段
				    textField:'modelname', //显示的字段
				    url:'${pageContext.request.contextPath}/sys/product.do?findByFreightModel',
				    panelHeight:'auto',
				    required:true,
					editable:false,//不可编辑，只能选择
					onChange:function(n,o){ 
					}
				});
				//当前商品状态
				var selectProStateData= [{currentstatus:1,currentstatusVal:'有限数量'},{currentstatus:2,currentstatusVal:'无限数量'},{currentstatus:3,currentstatusVal:'下架了'}];
				$("#selectProState").combobox({
					valueField:'currentstatus', //值字段
				    textField:'currentstatusVal', //显示的字段
				    //url:'',
				    data:selectProStateData,
				    panelHeight:'auto',
				    required:true,
					editable:false,//不可编辑，只能选择
					onChange:function(n,o){ 
					}
				});  
				
				});
		    
			function addOrUpdateProduct(){  
				//debugger; 
				//$("#description").val(FCKeditorAPI.GetInstance("description").GetXHTML());
				//$("#description").val(FCKeditorAPI.GetInstance("description").EditorDocument.body.innerText); 
				var r = $('#proForm').form('validate');
				if(!r) {
					return false;
				} 
				$("#description").val(FCKeditorAPI.GetInstance("description").GetXHTML());
				$("#proBrand").val($('#proBrandid').combobox('getText'));
				$.post("${pageContext.request.contextPath}/sys/product.do?addOrUpdate",$("#proForm").serializeArray(),function(data){
					$('#MyPopWindow').window('close');
					$('#proTable').datagrid('reload');  
					$.messager.alert('提示',data.msg,'info');
				});
			}
			$('#proPopPanel').panel();
		</script>
		<form id="proForm" method="post" style="margin: 10;text-align: center;">
			<div id="proPopPanel"  collapsible="true" style="padding:10px;">
				<div region="center" border="false" style="padding:10px;border:1px solid #ccc;">
					<input type="hidden" name="id" id="uuid">
					商品编号：<input type="text" name="productnum" style="width: 200px;border: 1px solid #ccc;padding: 2px;" validType="length[2,30]" class="easyui-validatebox" required="true" />
					商品名称：<input type="text" id ="popProductname" name="productname" style="width: 200px;border: 1px solid #ccc;padding: 2px;" validType="length[2,30]" class="easyui-validatebox" required="true" />
					商品品牌：<input name="brandid" id="proBrandid" style="width: 200px;border: 1px solid #ccc;padding: 2px;" /><input name="brand" id="proBrand" type="hidden" /><br /><br />
				          
				          厂商编号：<input type="text" name="manufacturernum" style="width: 200px;border: 1px solid #ccc;padding: 2px;"  class="easyui-validatebox" />
					成本价格：<input type="text" name="cost" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox" />
					商品类型：<input name="typeid" id="proTypeid" style="width: 200px;border: 1px solid #ccc;padding: 2px;" /><br /><br />	
					 			
					在售价格：<input type="text" name="onsaleprice" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox"  />
					公司价格：<input type="text" name="companyprice" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox"  />
					运费模板：<input name="freightid" id="proFreightid" style="width: 200px;border: 1px solid #ccc;padding: 2px;" /><br /><br />
					
					商品总数：<input type="text" name="totalamount" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox"  />
					剩余数量：<input type="text" name="quantityLeft" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox"  />
					商品状态：<input name="currentstatus" id="selectProState" style="width: 200px;border: 1px solid #ccc;padding: 2px;"  /><br /><br />
					
				    &nbsp;&nbsp;商品单位：<input type="text" name="unit" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox" />
					商品尺寸：<input type="text" name="size" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox" />
					商品简述：<input type="text" name="producttitle" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox" /><br /><br />
					
					&nbsp;&nbsp;装箱数量：<input type="text" name="packagenum" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox" />
					毛&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;重：<input type="text" name="grossWeight" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox"  />
				           重&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;量：<input type="text" name="weight" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox"  /><br /><br />
					
					&nbsp;&nbsp;产&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;地：<input type="text" name="placeOfOrigin" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox"  />
					包&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;装：<input type="text" name="packaging" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox"  />
					材&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;质：<input type="text" name="material" style="width: 200px;border: 1px solid #ccc;padding: 2px;"  class="easyui-validatebox"  /><br /><br />
					
					<!--  已售数量：<input type="text" name="sellamount" style="width: 200px;border: 1px solid #ccc;padding: 2px;" class="easyui-validatebox"  />-->
					商品描述：<textarea name="description" id="description"></textarea> 
					</div>
				<div region="south" border="false" style="text-align:right;height:30px;line-height:30px;">
					<a href="#" id="btn-back" onclick="closeWindow();" class="easyui-linkbutton" iconCls="icon-back">返回</a>
					<a href="#" id="btn-add" onclick="addOrUpdateProduct();" class="easyui-linkbutton" iconCls="icon-save">保存</a>
				</div>
			</div>
		</form> 
</body>
</html>